package top.lingkang.securityoauth2.server.auth.impl;

import top.lingkang.securityoauth2.core.entity.ClientDetail;
import top.lingkang.securityoauth2.core.entity.DefaultClientDetail;
import top.lingkang.securityoauth2.server.auth.ClientDetailService;
import top.lingkang.securityoauth2.server.error.Oauth2ServerException;

/**
 * @author lingkang
 * Created by 2022/7/8
 */
public class DefaultClientDetailService implements ClientDetailService {
    @Override
    public ClientDetail getClientDetail(String client_id,String client_secret, String grant_type) {
        if (!"client_id".equals(client_id))
            throw new Oauth2ServerException("不存在的client_id: " + client_id);
        if (!"password".equals(grant_type))
            throw new Oauth2ServerException("grant_type错误，应该为 password，当前: " + grant_type);
        if (!"client_secret".equals(client_secret))
            throw new Oauth2ServerException("client_secret错误");
        return new DefaultClientDetail("client_id", "client_secret", new String[]{"password"});
    }
}
